package br.org.etec.dotcao.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@NamedQueries({@NamedQuery(name="selectByStatus", query="select a from Animal a where a.status = :status")})
@Table(name="tanimal")
@Entity
public class Animal extends AbstractEntity {
	
	private static final long serialVersionUID = 1L;

	@Column
	private String name;

	@Column
	private String color;

	@Column
	private String age;

	@Column
	private String description;

	@Column
	private String temperament;

	@Column
	private String weight;

	@Column
	private String gender;

	@Enumerated(EnumType.STRING)
	private AnimalStatus status;

	@ManyToOne
	@JoinColumn(name="race")
	private Race race;
	
	@ManyToOne
	@JoinColumn(name="owner")
	private User owner;

	@OneToMany(cascade=CascadeType.ALL, mappedBy="animal")
	private List<AnimalPicture> pictures;
	
	public User getOwner() {
		return owner;
	}
	
	public void setOwner(User owner) {
		this.owner = owner;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getTemperament() {
		return temperament;
	}

	public void setTemperament(String temperament) {
		this.temperament = temperament;
	}

	public String getWeight() {
		return weight;
	}

	public void setWeight(String weight) {
		this.weight = weight;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender.toUpperCase();
	}

	public AnimalStatus getStatus() {
		return status;
	}

	public void setStatus(AnimalStatus status) {
		this.status = status;
	}

	public Race getRace() {
		return race;
	}

	public void setRace(Race race) {
		this.race = race;
	}

	public List<AnimalPicture> getPictures() {
		return pictures;
	}

	public void setPictures(List<AnimalPicture> pictures) {
		this.pictures = pictures;
	}
}
